mouse_pressed

This function checks if a particular mouse button has just been pushed down.

bool mouse_pressed(int button)

Parameters:
button
A mouse button number from 0 to 7 (see remarks).

Return value:
true if the button has just been pushed down, false if it has not or if an error occurs.

Remarks:
The difference between mouse_down and mouse_pressed is that mouse_pressed will only return true when the user first pushes down the button, while mouse_down will continue returning true until the button is released again.

The button number can be between 0 and 7, however not many mouse devices will have as many as 8 buttons. The numbers correspond to the following buttons:

Example:
// Wait for the user to press the left mouse button or the escape key before closing the program.

void main()
{
show_game_window("Test Game");
while(true)
{
mouse_update();
if(mouse_pressed(0) or key_pressed(KEY_ESCAPE))
{
exit();
}
// Other code goes here.
wait(5);
}
}